package com.hqj.demo01;

import org.omg.Messaging.SyncScopeHelper;

/**
 * static静态关键字
 * @author HQJ
 */
public class StaticClass {

    public static void main(String[] args) {
        TestStatic ts1 = new TestStatic();
       /* TestStatic ts2 = new TestStatic();
        ts2.method01();*/
    }


}
class TestStatic{
    //静态代码块  数据库的连接请求
    static{
        System.out.println("这里是静态代码块");
    }

    public TestStatic(){
        System.out.println("无参构造方法");
    }

    public String name;
    public int age;
    public static int num;//当前在线人数


    public void method01(){//非静态方法
        age = age +1;
        num = num +1;
        System.out.println("age:"+age+",num:"+num);
    }

    public static void method02(){//静态方法
        TestStatic ts = new TestStatic();
        System.out.println(ts.name+"--"+ts.age+"---"+num);
        ts.method01();
    }

}
